import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:tiktokadult/assets_tool/images.dart';
import 'package:tiktokadult/config/config.dart';
import 'package:tiktokadult/hj_utils/widget_utils.dart';
import 'package:tiktokadult/routers/jump_router.dart';

import '../hj_model/user/aw_info_resp.dart';
import '../tools_base/debug_log.dart';
import '../hj_utils/api_service/vid_service.dart';

class AwPermissionAlert extends StatefulWidget {
  AwPermissionAlert();

  @override
  State<StatefulWidget> createState() {
    return _AwPermissionAlertState();
  }
}

class _AwPermissionAlertState extends State<AwPermissionAlert> {
  static AwInfoResp? awInfoResp;
  bool isLoadingData = true;
  @override
  void initState() {
    super.initState();
  }

  void _loadData({bool retry = false}) async {
    try {
      awInfoResp = await VidService.fetchAwVipInfo();
      isLoadingData = false;
    } catch (e) {
      debugLog(e);
      if (retry) {
        _loadData(retry: false);
      } else {
        isLoadingData = false;
      }
    }
    if (mounted) setState(() {});
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      color: Colors.black.withOpacity(0.4),
      child: BackdropFilter(
        filter: ImageFilter.blur(
          sigmaX: 20,
          sigmaY: 20,
        ),
        child: Center(
          child: Material(
            color: Colors.transparent,
            child: GestureDetector(
              behavior: HitTestBehavior.opaque,
              onTap: () => jumpToWalletPage(tabPosition: 0),
              child: Column(
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  Text(
                    '暗网含有全球禁止流出的极其稀缺的资源\n'
                    '变态重口、真实强奸、猎奇重口、韩国N号\n'
                    '房、人兽杂交、缅北禁地、真实破处、血\n'
                    '腥战场、兽父等等\n'
                    '百万罕见稀缺的资源，\n'
                    '仅对少量用户开放\n\n'
                    '内容过于真实，可能会引起极度不适\n'
                    '请谨慎进入！禁止分享传播！\n\n'
                     '马上开通\n\n'
                      '${Config.darkWebVipName}\n'
                     '即可获得无限观看暗网视频资格\n',
                    textAlign: TextAlign.center,
                    style: TextStyle(
                      color: Color(0xffFD2D55),
                      fontSize: 16,
                      fontWeight: FontWeight.w500,
                    ),
                  ),
                  24.sizeBoxH,
                  InkWell(
                    onTap: () {
                      jumpToWalletPage(vipId: Config.darkWebVipId);
                    },
                    child: Container(
                      width: 300,
                      height: 44,
                      alignment: Alignment.center,
                      decoration: BoxDecoration(
                        color: Color(0xffFF004C),
                        borderRadius: BorderRadius.circular(4),
                      ),
                      child: Text(
                        '立即开通',
                        textAlign: TextAlign.center,
                        style: TextStyle(
                          color: Colors.white,
                          fontSize: 14,
                          fontWeight: FontWeight.w500,
                        ),
                      ),
                    ),
                  ),
                ],
              ),
            ),
          ),
        ),
      ),
    );
  }
}
